const Koa = require('koa');
const Router = require('koa-router');
const cors = require('@koa/cors');
const app = new Koa();
const router = new Router();
app.use(cors());
router.get('/', ctx => {
    ctx.body = 'hello';
});

const textArr = []
router.get('/li', ctx => {
    ctx.body = textArr;
});

router.get('/text', ctx => {
    console.log(ctx.query)
    let obj = ctx.query
    if(obj.name){
        textArr.push(ctx.query)
    }
    ctx.body = ctx.query;
});

//启动路由
app.use(router.routes());
app.use(router.allowedMethods());

app.listen(3000);